<!-- 第9章/HomeSharing/app/views/layout.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{{title}}</title>
    <link rel="stylesheet" href="/static_files/libs/bootstrap-4.4.1-dist/css/bootstrap.min.css">

    <script src="/static_files/libs/jquery.min.js"></script>
    <script src="/static_files/libs/bootstrap-4.4.1-dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-sm navbar-light bg-light">
    <a class="navbar-brand" href="/house/all">房屋直租</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item">
                <a class="nav-link" href="/house/all">房源</a>
            </li>
        </ul>
        <form class="form-inline my-2 my-lg-0" action="/house/search" method="get">
            <input name="k" class="form-control mr-sm-2" type="search" placeholder="关键字" aria-label="Search">
            <button class="btn btn-outline-success my-2 my-sm-0" type="submit">搜索</button>
        </form>
        <ul class="navbar-nav">
            {% if 'current_user' in session and session['current_user'] %}
            {% set user = session['current_user'] %}
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
                   aria-haspopup="true" aria-expanded="false">
                    {{ user['user_name'] }}
                </a>
                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                    <a class="dropdown-item" href="/user/profile">我的信息</a>
                    <a class="dropdown-item" href="/user/pub_house">发布房源</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="/user/logout">登出</a>
                </div>
            </li>
            {% else %}
            <li class="nav-item">
                <a class="nav-link" href="/user/login">登录</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="/user/register">注册</a>
            </li>
            {% endif %}
        </ul>
    </div>
</nav>
<div class="container">
    {% block body %}{% endblock %}
</div>
</body>
</html>